package com.bua.datafactory;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.bua.dao.OrderItem;

public class OrderListDataFactory extends DataFactory {
    public OrderItem[] orderItem;
    public int page;
    public int total;

    public OrderListDataFactory(String jsonString) {
        super(jsonString);
        if (status == 200) {
            try {
                page = body.getInt("page");
                total = body.getInt("total");
                JSONArray orderArray = body.getJSONArray("orderList");
                int size = orderArray.length();
                orderItem = new OrderItem[size];
                for (int index = 0; index < size; index++) {
                    OrderItem item=new OrderItem();
                    item.orderId = orderArray.getJSONObject(index).getString("orderID");
                    item.patientName = orderArray.getJSONObject(index).getString("patientName");
                    item.dentistName = orderArray.getJSONObject(index).getString("dentistName");
                    item.createdDate = orderArray.getJSONObject(index).getString("created");
                    item.updateDate = orderArray.getJSONObject(index).getString("modified");
                    orderItem[index]=item;
                }

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
